<template>
    <div >
        <el-form
            ref="formRef"
            :model="formObject"
            label-width="130px"
            label-position="left"
            class="mt20"
            :disabled="isTask"
        >
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="投标客户名称">
                        <el-input v-model="formObject.customerName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="招标项目资金来源">
                        <el-select
                            v-model="formObject.capitalSource"
                            placeholder="请选择"
                            style="width: 100%"
                        >
                            <el-option
                                v-for="item in capitalSourceOptions"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                            >
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="项目简介">
                        <el-input v-model="formObject.projectDesc"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="招标项目概况">
                        <el-input
                            v-model="formObject.projectOverview"
                        ></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="投标时间">
                        <el-date-picker
                            v-model="formObject.tenderTime"
                            type="date"
                            placeholder="选择日期"
                            style="width: 100%"
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="开标日期">
                        <el-date-picker
                            v-model="formObject.bidOpenTime"
                            type="date"
                            placeholder="选择日期"
                            style="width: 100%"
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="购买标书时间">
                        <el-date-picker
                            v-model="formObject.buyBidTime"
                            type="date"
                            placeholder="选择日期"
                            style="width: 100%"
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="保证金退还日期">
                        <el-date-picker
                            v-model="formObject.ensureBackTime"
                            type="date"
                            placeholder="选择日期"
                            style="width: 100%"
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="保证金金额">
                        <el-input v-model="formObject.ensureMoney"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="竞争对手">
                        <el-input v-model="formObject.competitors"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="是否需要保证金">
                        <el-radio
                            v-model="formObject.isEnsure"
                            :label="1"
                            border
                            >是</el-radio
                        >
                        <el-radio
                            v-model="formObject.isEnsure"
                            :label="2"
                            border
                            >否</el-radio
                        >
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="有无内部资源">
                        <el-radio
                            v-model="formObject.isInsideResource"
                            :label="1"
                            border
                            >有</el-radio
                        >
                        <el-radio
                            v-model="formObject.isInsideResource"
                            :label="2"
                            border
                            >无</el-radio
                        >
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="招标方式">
                        <el-radio
                            v-model="formObject.tenderingType"
                            :label="2"
                            border
                            >邀标</el-radio
                        >
                        <el-radio
                            v-model="formObject.tenderingType"
                            :label="3"
                            border
                            >仪标</el-radio
                        >
                        <el-radio
                            v-model="formObject.tenderingType"
                            :label="1"
                            border
                            >公开招标</el-radio
                        >
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="备注">
                        <el-input
                            v-model="formObject.remarks"
                            type="textarea"
                        ></el-input>
                    </el-form-item>
                </el-col>
            </el-row> -->
        </el-form>
    </div>
</template>
<script>
import { addTenderList, editTenderList  } from "@/api/system/tender";
export default {
    data() {
        return {
            formObject: {
                businessType: "1",
                bidOpenTime: "",
                buyBidTime: "",
                capitalSource: "",
                changeTime: "",
                competitors: "",
                createTime: "",
                customerId: "",
                customerName: "",
                ensureBackTime: "",
                ensureMoney: "",
                id: "",
                isEnsure: 0,
                isInsideResource: "",
                projectDesc: "",
                projectOverview: "",
                tenderTime: "",
                tenderingType: 0,
            },
            capitalSourceOptions: [
                {
                    label: "自筹",
                    value: 1,
                },
                {
                    label: "财政拨款",
                    value: 2,
                },
                {
                    label: "政府补贴",
                    value: 3,
                },
                {
                    label: "其他",
                    value: 4,
                },
            ],
        };
    },
    computed:{
    isTask() {
      return this.$store.state.workflow.formType.includes("task") ;
    },
    isEdit() {
      return this.$store.state.workflow.formType === 'edit' ;
    },
  },
    methods: {
         //获取回显数据
    getFormData() {
        if(this.$store.state.workflow.businessConfig.formData){
            this.formObject = this.$store.state.workflow.businessConfig.formData;
        }
    },
        submit() {
            this.formObject.modelId = this.$store.state.workflow.businessConfig.id
                if(this.isEdit){
                    editTenderList(this.formObject).then((res) => {
                    if (res.code === 200) {
                        this.$message({
                            message: "修改成功！",
                            type: "success",
                        });
                        this.$store.commit("workflow/SET_BUSINESSDRAWER", false);
                    }
                });
                return
            }
            addTenderList(this.formObject).then((res) => {
                if (res.code === 200) {
                    this.$message({
                        message: "新增成功！",
                        type: "success",
                    });
                    this.$store.commit("workflow/SET_BUSINESSDRAWER", false);
                }
            });
        },
    },
    created() {
        this.getFormData()
    },
};
</script>
<style lang="scss" scoped>
.divider {
    margin: 0;
}
</style>
